/*
 *	ApOS (Another Project software for s3c2410)
 *	
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *			
 *
 */
#include "../include/kernel/data_abort.h"
#include "../include/s3c2410/cpu.h"
//#define _ABT_DEBUG
void do_data_abort(struct cpu_registers *regs)
{
	unsigned int sfr=read_data_fsr();
	unsigned int fault_info=0;;
	
	#ifdef _ABT_DEBUG
		printk("data abort.\n");
		printk("fault status: ");
	#endif
	if((((sfr&0x0000000f)>>2)&0x3)==0x0)
	{
		#ifdef _ABT_DEBUG
			printk("alignment abort.\n");
		#endif
		panic();
	}
	else
	{
		switch(sfr&0x0000000f)
		{
			case FS_TRANSLATION0:
			case FS_TRANSLATION1:
				fault_info=read_far();
				#ifdef _ABT_DEBUG
					printk("translation fault.\n");
					printk("fault address :0x%0x\n",fault_info);
				#endif
				do_address_fault(fault_info);
				break;
				
			case FS_DOMAIN0:
			case FS_DOMAIN1:
				panic("domain fault.\n");
				break;
				
			case FS_PERMISSION0:
			case FS_PERMISSION1:
				fault_info=read_far();
				#ifdef _ABT_DEBUG
					printk("permission fault.\n");
					printk("fault address :0x%0x\n",fault_info);
				#endif				
				panic("perssion fault.\n");
				break;

			case FS_EXTERNAL_ABORT0:
			case FS_EXTERNAL_ABORT1:
				panic("external abort.\n");
				break;
		}
		
	}
}